package cn.itcast.ssm.localeResolver;

import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

/**
 * Description:
 * Created by t410 on 2017/7/5.
 */
public class MyAcceptHeaderLocaleResolver extends AcceptHeaderLocaleResolver {
    private Locale myLocal;

    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        return myLocal!=null?myLocal:request.getLocale();
    }

    @Override
    public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
        this.myLocal = locale;
    }

    public Locale getLocale() {
        return myLocal;
    }
}
